<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
  <style>
    li{
      list-style: none;
      width: 500px;
      height:50px;
      margin-top:5px;
      background: rgb(204, 112, 112);
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="delArr">删除</button>
    <ul>
      <li v-for="(item,index) in arr" @click="changeArr(index)" :key="index">
        {{item}}
      </li>
    </ul>
  </div>
  <script>
    let vm = new Vue({
      el: "#app",
      data: {
        arr: [1, 2, 3, 4]
      },
      methods:{
        changeArr (index) {
          /*
          this.arr[index] = 100;
          console.log(this.arr)
          */
         this.$set(this.arr,index,100)
        },
        delArr(){
          this.arr.length = this.arr.length-1;
          console.log(this.arr)
        }
      }
    })
    /*
      [
        {
          name:111
        }
      ]

      this.arr[0].name = 222
    */
  </script>
</body>
</html>
